package com.exercise.AndroidCamera;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
/*
기능 : 반경설정
작성 : 하드캔
완료일 : 2014.09.26 
	*/
public class SettingRadiusActivity extends BaseActivity {

	Intent mIntent;
	String userID;
	Double meter;
	
	private double range;
	RadioGroup select_radius;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_setting_radius);
		
		userID = getIntent().getExtras().getString("userID");
		meter = getIntent().getExtras().getDouble("meter");
		select_radius = (RadioGroup)this.findViewById(R.id.radius_group);
		getActionBar().setTitle("Post Memories");
		getActionBar().setDisplayShowHomeEnabled(false);
		getActionBar().setDisplayHomeAsUpEnabled(true);
		
	
		if(meter == 0.5){
			select_radius.check(R.id.fiveoometer);
			
		}else if(meter == 1.0){
				select_radius.check(R.id.onekilometer);
				
		}else if(meter == 3.0){
			select_radius.check(R.id.threekilometer);
				
		}else if(meter ==5.0){
			select_radius.check(R.id.fivekilometer);
				
		}
		findViewById(R.id.fiveoometer).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				range = 0.5;
			}
		});
		findViewById(R.id.onekilometer).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				range = 1.0;
			}
		});
		findViewById(R.id.threekilometer).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				range = 3.0;
				}
			});
		findViewById(R.id.fivekilometer).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				range = 5.0;
			}
		});
		
		findViewById(R.id.btnOK).setOnClickListener(
				new View.OnClickListener() {
					@Override
					public void onClick(View view) {
				    	mIntent = new Intent(SettingRadiusActivity.this, MainActivity.class);
				        mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				    	mIntent.putExtra("userID", userID);
				    	Log.d("range2",""+range);
				    	mIntent.putExtra("select_radius", range);
			    		startActivity(mIntent);
					}
				});
	}
	
	
	
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	     
	    switch(item.getItemId()){
	    
	    case android.R.id.home:
	    	onBackPressed();
	    	break;

	    default:
	        return false;
	    }
	    return true;
	}
}
